package com.example.yls.demoa;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class MyFrontService extends Service {
    public MyFrontService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Intent intent=new Intent(MyFrontService.this,MainFrontActivity.class);
        PendingIntent pi=PendingIntent.getActivity(MyFrontService.this,0,intent,0);
        Notification notification=new Notification.Builder(MyFrontService.this)
                .setContentTitle("天气预告")
                .setContentText("今天15度")
                .setSmallIcon(R.mipmap.ic_launcher)
                .setWhen(System.currentTimeMillis())
                .setContentIntent(pi)
                .build();
        startForeground(1,notification);
    }
}
